<template>
  <footer class="footer">
    <!-- 当任务全部完成后，任务框全部选中完成，隐藏剩余的状态栏 -->
    <span class="todo-count" v-show="selectNum">
      <strong>{{ selectNum }} </strong>剩余
    </span>
    <ul class="filters">
      <li>
        <a
          :class="{ selected: type === 'all' }"
          href="#/"
          @click="selectList('all')"
          >全部
        </a>
      </li>
      <li>
        <a
          href="#/active"
          :class="{ selected: type === 'active' }"
          @click="selectList('active')"
          >进行中</a
        >
      </li>
      <li>
        <a
          href="#/completed"
          :class="{ selected: type === 'completed' }"
          @click="selectList('completed')"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="allDone">清除已完成</button>
  </footer>
</template>

<script>
export default {
  name: 'TodoFooter',
  props: {
    selectNum: {
      type: Number,
      required: true,
    },
    type: {
      type: String,
      required: true,
    },
  },
  methods: {
    selectList(type) {
      this.$emit('selectList', type)
    },
    allDone() {
      this.$emit('allDone')
    },
  },
}
</script>

<style scoped lang="less"></style>
